package com.spel.validate.annotation;


import com.spel.validate.enums.AssertTypeEnum;
import com.spel.validate.exception.NoPermissionException;
import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 判断是否具有权限注解
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Inherited
@BaseAssert
public @interface HasPermissions {

    @AliasFor(annotation = BaseAssert.class)
    AssertTypeEnum assertType() default AssertTypeEnum.PERMISSION_ASSERT;

    @AliasFor(annotation = BaseAssert.class)
    Class<?> validatorBeanClass() default Void.class;

    @AliasFor(annotation = BaseAssert.class)
    String[] value() default {};

    @AliasFor(annotation = BaseAssert.class)
    String[] expression() default {};

    @AliasFor(annotation = BaseAssert.class)
    Class<? extends RuntimeException>[] ifError() default {NoPermissionException.class};

    @AliasFor(annotation = BaseAssert.class)
    String errorMsg() default "权限不足!";
}
